[#import "/framework/JGP.htm"  as JGP]
<!--
项目   jgp-cloud-parent
作者   LOUFEI [Gavin]
时间   2020/9/29
-->
[@JGP.head "Title"/]
[@JGP.body]
    <jgp-div  _row="['80','*']" _runit="px">
    <div slot="1-1">
        <jgp-query _id="query" _target="resGrid" _action="/security/resource-api-ctl/query">
            <jgp-form-group _title="资源搜索">
                <jgp-text _col="4" _name="remark" _placeholder="资源描述"></jgp-text>
                <jgp-text _col="4" _name="action" _placeholder="权限标识符"></jgp-text>
                <jgp-drop _col="4" _name="powerType" _not_input="true"
                          _list="[{'label':'功能类型选择','value':''},
                               {'label':'访问控制','value':'PAGE'},
                               {'label':'异步操作','value':'API'},
                               {'label':'服务','value':'SERVICE'}]"></jgp-drop>
            </jgp-form-group>
        </jgp-query>
    </div>
    <div slot="2-1">
        <jgp-grid _id="resGrid" _oncheck="checkFn" _cols="['*','150','80']" _cunit="px" ></jgp-grid>
    </div>
    </jgp-div>
[/@JGP.body]

[@JGP.foot]
    <script>
        var roleId = '${roleId}';
        JGP.$onload(function () {
            JGP.$post('/security/role-res-api-ctl/query-res',{roleId:roleId},function (result) {
                console.log(result);
                JGP.grid('resGrid').setSelected(result.data.resources);
            })
        })
        function checkFn(args) {
            if(args.back.checked){
                JGP.$post('/security/role-res-api-ctl/add-res',{roleId:roleId,resId:args.back.record.id},function (result) {
                    console.log(result);
                })
            }else{
                JGP.$post('/security/role-res-api-ctl/remove-res',{roleId:roleId,resId:args.back.record.id},function (result) {
                    console.log(result);
                })
            }
        }
    </script>
[/@JGP.foot]